package com.huhao.wshare.controller;

import com.huhao.wshare.dto.EmailRequest;
import com.huhao.wshare.dto.AjaxResult;
import com.huhao.wshare.service.VerifyCodeService;
import com.huhao.wshare.service.constant.VerificationCodeType; // 新增导入
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/auth")
public class VerifyCodeController {

    @Autowired
    private VerifyCodeService verifyCodeService;

    @PostMapping("/sendCode")
    public AjaxResult<String> sendVerificationCode(@RequestBody EmailRequest request) {
        // 修改调用，明确指定验证码类型为注册
        return verifyCodeService.sendVerificationCode(request.getEmail(), VerificationCodeType.REGISTRATION);
    }
}
